home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / XCMDs / XCMDTools++ / xcmdBase.h < prev    next >
Encoding:
Text File  |  1995-10-05  |  2.4 KB  |  75 lines  |  [TEXT/CWIE]

  1. //    © Paul B. Beeken, Work In Progress, 1994-5
  2. //    Knowledge Software Consulting.
  3. //
  4. //    These files are a mindlessly simple wrapper class for the
  5. //    basic XCMD operations.  Only one instance of the xcmdBase class is
  6. //    generated per XCMD call but there may be many instances of the XCMDString
  7. //    class.  I have used these classes to whip out XCMD/XFCNs within hours of
  8. //    receiving the specs.  They work great for me but I will always consider 
  9. //    suggestions.
  10. //
  11. //    Please, please, please, in the unlikely event you should use this stuff
  12. //    for some commercial application I would appreciate you contacting me.  If
  13. //    its for your own use, use away. Send email: knowsoft@ios.com
  14. //
  15. //    As always: this file is presented as is with no warrantees expressed or implied.
  16. //    Swim at your own risk, etc. etc.
  17.  
  18. #pragma once
  19.  
  20. #include    "xcmdStrings.h"
  21.  
  22. #ifndef    __HYPERXCMD__
  23. #include    <HyperXCmd.h>
  24. #endif
  25.  
  26. //
  27. //    This is the base class for all xcmds and  xfcns.
  28. //        Only one of these objects is instantiated in the xcmd or xfcn code
  29. //        resource.  It will setup xcmdString's static objects which handles
  30. //        the critical and very ambiguous strings required in these code resources.
  31. //
  32. class    xcmdBase    {
  33.  
  34.     friend    class    xcmdString;            // has to be our friend for us to set it up
  35.  
  36.     private:
  37.         XCmdPtr        paramPtr;
  38.         Boolean        paramsLocked;
  39.  
  40.     protected:
  41.         void    passMsg( Boolean p )    { paramPtr->passFlag = p; }
  42.         XCmdPtr    theParamPtr( void )        { return paramPtr; }
  43.         void    lockParams( void );
  44.         void    unlockParams( void );
  45.  
  46.     public:
  47.         xcmdBase( XCmdPtr xP, Boolean lockParams=false );
  48.         ~xcmdBase( void );
  49.  
  50.         /****  HyperTalk Utilities  ****/
  51.         Handle        evalExpr( xcmdString expr );            // expression evaluation
  52.         void        sendCardMessage( xcmdString msg );        // curr. card a message
  53.         void        sendHCMessage( xcmdString msg );        // hypercard a message
  54.         void        runScript( xcmdString handler );        // run an explicit script
  55.  
  56.         /****  Memory Utilities  ****/
  57.         void        getGlobal( xcmdString globName, xcmdString* rs );
  58.         void        setGlobal( xcmdString globName, xcmdString& globValue );
  59.         void        zeroBytes( Ptr dstPtr, long longCount );
  60.         
  61.         /****  My special additions  ****/  /* ALL NEW */
  62.         void    errorMsg( xcmdString message );
  63.         void    returnMsg( xcmdString message );
  64.         void    returnNil( void )        { paramPtr->returnValue = nil; }
  65.  
  66.         short    nParams( void )            { return paramPtr->paramCount; }
  67.         Boolean    checkParameters( int min, int max=0 );
  68.  
  69.         Handle    operator[]( const int i );
  70.         
  71.     };
  72.  
  73.  
  74.  
  75.